﻿// MyDialog.cpp: 实现文件
//

#include "pch.h"
#include "MFCApplication1.h"
#include "MyDialog.h"
#include "afxdialogex.h"
#include "MFCApplication1Doc.h"

// MyDialog 对话框

IMPLEMENT_DYNAMIC(MyDialog, CDialogEx)

MyDialog::MyDialog(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_DIALOG1, pParent)
{

}

MyDialog::~MyDialog()
{
}

void MyDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_EDIT1, EditButton);
	DDX_Control(pDX, IDC_BUTTON1, Button);
}


BEGIN_MESSAGE_MAP(MyDialog, CDialogEx)
	ON_BN_CLICKED(IDC_BUTTON1, &MyDialog::OnClickedButton1)
END_MESSAGE_MAP()


// MyDialog 消息处理程序


void MyDialog::OnClickedButton1()
{
	// TODO: 在此添加控件通知处理程序代码
	
	CString str;
	this->EditButton.GetWindowTextW(str);
	CDC* pDC = GetParent()->GetDC();
	pDC->TextOutW(500, 500, str);
	CMFCApplication1Doc* doc = (CMFCApplication1Doc*)GetParentFrame()->GetActiveView()->GetDocument();
	doc->m_str = str;
	EndDialog(-1);
}

void MyDialog::clear() {
	//清屏函数，除提示消息外的所有消息都会被清空、置为初始状态
	CDC* pDC = GetParent()->GetDC();
	CRect rc;
	GetClientRect(&rc);
	//通过覆盖一个填充为白色的矩形实现
	pDC->FillSolidRect(&rc, RGB(255, 255, 255));
	//释放设备上下文环境
	ReleaseDC(pDC);
}